﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Wolfy.NetDisk.Core.Repository
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    public interface IRepository<T>
    {
        /// <summary>
        /// 根据id查询实体
        /// </summary>
        /// <param name="id">主键id</param>
        /// <returns></returns>
        T Get(int id);
        /// <summary>
        /// 获取所有的实体
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="predicate"></param>
        /// <param name="showDeleted"></param>
        /// <returns></returns>
        IQueryable<T> Where(Expression<Func<T, bool>> predicate, bool showDeleted = false);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T Insert(T entity);
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T Update(T entity);
        /// <summary>
        /// 保存
        /// </summary>
        void Save();
        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entity"></param>
        void Delete(T entity);
        /// <summary>
        /// 还原
        /// </summary>
        /// <param name="entity"></param>
        void Restory(T entity);
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecord"></param>
        /// <param name="where"></param>
        /// <param name="isAsc"></param>
        /// <param name="orderLambda"></param>
        /// <returns></returns>
        IQueryable<T> FindPaged(int pageIndex, int pageSize, out int totalRecord, Expression<Func<T, bool>> where, bool isAsc, Expression<Func<T, dynamic>> orderLambda);

      
    }
}
